#include<stdio.h>
#include<math.h>
int main()
{
	for (int x = 1; x <= 100000; x++)
	{
		int arr[6] = { 0 };
		arr[0] = x % 10;
		arr[1] = (x / 10) % 10;
		arr[2] = (x / 100) % 10;
		arr[3] = (x / 1000) % 10;
		arr[4] = (x / 10000) % 10;
		arr[5] = (x / 100000) % 10;
		int bit;
		if (arr[5] != 0)bit = 6;
		else if (arr[4] != 0)bit = 5;
		else if (arr[3] != 0)bit = 4;
		else if (arr[2] != 0)bit = 3;
		else if (arr[1] != 0)bit = 2;
		else if (arr[0] != 0)bit = 1;
		if (x == pow(arr[0], bit) + pow(arr[1], bit) + pow(arr[2], bit) + pow(arr[3], bit) + pow(arr[4], bit) + pow(arr[5], bit))
			printf("%d ", x);

	}
	return 0;
}